home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / tobby_on_ice.swf / scripts / DefineSprite_158 / frame_1 / DoAction.as
Text File  |  2011-08-19  |  1KB  |  55 lines

  1. function main()
  2. {
  3.    if(_root.pauseFlg)
  4.    {
  5.       return undefined;
  6.    }
  7.    switch(this.stat)
  8.    {
  9.       case "walk":
  10.          this.walk();
  11.          break;
  12.       case "stay":
  13.    }
  14. }
  15. function walk()
  16. {
  17.    var _loc1_ = this;
  18.    _loc1_._x += _loc1_.pdx;
  19.    if(_loc1_._x > 130)
  20.    {
  21.       _loc1_._x = 130;
  22.       _loc1_.pdx = -4;
  23.       _loc1_._xscale = -100;
  24.    }
  25.    if(_loc1_._x < 20)
  26.    {
  27.       _loc1_._x = 20;
  28.       _loc1_.pdx = 4;
  29.       _loc1_._xscale = 100;
  30.    }
  31.    if(_loc1_.stat != "stay")
  32.    {
  33.       if(_loc1_.hitMC.hitTest(_root.tobbyMC.hitMC))
  34.       {
  35.          var _loc2_ = _root.tobbyMC.hitJr(_loc1_.pdx);
  36.          if(_loc2_)
  37.          {
  38.             _loc1_.stat = "stay";
  39.             _loc1_.anmMC.gotoAndPlay("win");
  40.          }
  41.       }
  42.    }
  43. }
  44. function reset()
  45. {
  46.    var _loc1_ = this;
  47.    _loc1_._xscale = 100;
  48.    _loc1_.pdx = 4;
  49.    _loc1_.stat = "walk";
  50.    _loc1_.anmMC.gotoAndPlay("walk");
  51. }
  52. this.pdx = 4;
  53. this.stat = "walk";
  54. this._x = 20 + _root.randomInt(100);
  55.